package com.tool_stdy.thread;

/**
 * Created by yan_li on 2016/1/12.
 */
public class ThreadSee {
    public static void main(String[] args) throws InterruptedException {
        ThReadTest th=  new ThReadTest();
        Thread t1 = new Thread(th);
        t1.start();
        Thread.sleep(1000);
        th.changeFlag();
        t1.join();
        System.out.println(th.getFlag());
    }

}


class ThReadTest implements Runnable{

    boolean  stopflag = false;
    @Override
    public void run() {
        int i=0;
        while(!stopflag){
            i++;
        }
        System.out.println("Thread finish:"+i);
    }
    public void changeFlag(){
        this.stopflag=true;
        System.out.println(Thread.currentThread().getName()+"***********");
    }

    public boolean getFlag(){
        return stopflag;
    }
}
